package com.xiaoshuidi.cloud.module.report.controller.datamanage;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.module.report.controller.datamanage.vo.*;
import com.xiaoshuidi.cloud.module.report.enums.ApiConstants;
import com.xiaoshuidi.cloud.module.report.service.datamanage.RoomStatisticsService;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;


import static com.xiaoshuidi.cloud.framework.common.pojo.CommonResult.success;

/**
 * 房源统计
 */
@Slf4j
@Validated
@RestController
@RequestMapping(ApiConstants.DATA_MANAGE + "/room-statistics")
public class RoomStatisticsController {

    @Resource
    private RoomStatisticsService roomStatisticsService;

    @PostMapping("/empty-room-statistics")
    @Operation(summary = "空置房统计")
    public CommonResult<RmptyRoomStatisticsRespVO> emptyRoomStatistics(@RequestBody RmptyRoomStatisticsReqVO reqVO) {
        return success(roomStatisticsService.emptyRoomStatistics(reqVO.getApartmentIds(), reqVO.getIncludeModelMaintenanceRooms()));
    }

    @PostMapping("/empty-room-rate-statistics")
    @Operation(summary = "空置率统计")
    public CommonResult<EmptyRoomRateStatisticsRespVO> emptyRoomRateStatistics(@RequestBody @Valid EmptyRoomRateStatisticsReqVO reqVO) {
        return success(roomStatisticsService.emptyRoomRateStatistics(reqVO.getApartmentIds(), reqVO.getStartDate(), reqVO.getEndDate()));
    }

    @PostMapping("/empty-room-damages-statistics")
    @Operation(summary = "空置损失统计")
    public CommonResult<EmptyRoomDamagesStatisticsRespVO> emptyRoomDamagesStatistics(@RequestBody @Valid EmptyRoomDamagesStatisticsReqVO reqVO) {
        return success(roomStatisticsService.emptyRoomDamagesStatistics(reqVO.getApartmentIds(), reqVO.getCondition(), reqVO.getStartDate(), reqVO.getEndDate()));
    }
}
